package com.dormitory.dormitorymanagement.mapper;


import com.dormitory.dormitorymanagement.pojo.ClassNotice;
import com.dormitory.dormitorymanagement.pojo.CourseSchedule;
import com.dormitory.dormitorymanagement.pojo.CourseUpload;
import com.dormitory.dormitorymanagement.pojo.StudentEvaluations;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ClassLeaderMapper {

    /**
     * 保存课表
     * @param courseUpload
     */
    @Insert("insert into dormitory.course_upload(semester, remark, file_name, file_path, student_id, upload_time) values (#{semester},#{remark},#{fileName},#{filePath},#{studentId},#{uploadTime})")
    void save(CourseUpload courseUpload);



    @Insert("insert into dormitory.class_notice(title, content, student_id, student_name, student_class, student_role, create_time) values (#{title},#{content},#{studentId},#{studentName},#{studentClass},#{studentRole},#{createTime})")
    void notice(ClassNotice notice);


    /**
     * 添加课表
     * @param course
     */

    @Insert("insert into dormitory.course_schedule(course_name, teacher_name, semester, day_of_week, time_period, classroom, create_time,class_name) values (#{courseName},#{teacherName},#{semester},#{dayOfWeek},#{timePeriod},#{classroom},#{createTime},#{className})")
    void add(CourseSchedule course);

    /**
     *
     * 根据班级名查询课表
     * @param className
     * @return
     */

    @Select("select * from dormitory.course_schedule where class_name = #{className}")
    List<CourseSchedule> findByClassName(String className);


    /**8
     *  删除课表
     * @param className
     */
    @Delete( "delete from dormitory.course_schedule where class_name = #{className}")
    void delete(String className);


    /***
     * 获取同学的评价
     * @param studentId
     * @return
     */

    @Select( "select * from dormitory.student_evaluations where target_id = #{studentId} and target_role = 'class'")
    List<StudentEvaluations> getStudentClassmateEvaluations(String studentId);
}
